



use "Replication.Package\Data\tmp_2018b1_male", clear
merge m:1 a01 using "Replication.Package\Data\tmp_2015a_region"
drop _merge
merge m:1 a01 using "Replication.Package\Data\tmp_2018a_male.dta"
drop _merge
merge m:1 a01 mid using "Replication.Package\Data\tmp_2018z1_female.dta"
drop _merge
merge m:1 a01 mid using "Replication.Package\Data\tmp_2018z3_female.dta"
drop _merge
merge m:1 a01 mid using "Replication.Package\Data\tmp_2018z4_female.dta"
drop _merge
merge m:1 a01 mid using "Replication.Package\Data\tmp_2018xxab.dta"
drop _merge
merge m:1 a01 mid using "Replication.Package\Data\tmp_2018we_merge.dta"
drop _merge

g myear = 2018-age+mage
g birthyear = 2018-age

*Sample and the level of clustering
gen fsample=0
replace fsample=1 if sex==2 & mstatus==2 & dcode!=.
replace fsample=0 if x1==2
replace fsample=0 if mage>30
replace fsample=0 if hreligion==5
replace fsample=0 if birthyear<1960
replace fsample=0 if birthyear>2004

keep if fsample==1

g decade = 1 if myear>=1970 & myear<1980
replace decade = 2 if myear>=1980 & myear<1990
replace decade = 3 if myear>=1990 & myear<2000
replace decade = 4 if myear>=2000 & myear<2010
replace decade = 5 if myear>=2010 

gen cm=(mage<18 ) if mage!=.
label var cm "Child marriage"

*Dependent variables
gen bargaining_birth=(birthcontrol_decisionmaker==1 | birthcontrol_decisionmaker==3) if birthcontrol_decisionmaker!=.
gen bargaining_edu=(decisionmaker_education==1 | decisionmaker_education==3) if decisionmaker_education!=.
g threaten_divorce2 = (threaten_divorce <=3 ) if threaten_divorce!=.
g threaten_anotherwife2 = (threaten_anotherwife <=3 ) if threaten_anotherwife!=.
g abuse_verbally2 = (abuse_verbally <=3 ) if abuse_verbally!=.
g abuse_physically2 = (abuse_physically <=3 ) if abuse_physically!=.
g abuse_verbally_anothermale2 = (abuse_verbally_anothermale <=3 ) if abuse_verbally_anothermale!=.
g abuse_verbally_anotherfemale2 = (abuse_verbally_anotherfemale <=3 ) if abuse_verbally_anotherfemale!=.
g abuse_physically_anothermale2 = (abuse_physically_anothermale <=3 ) if abuse_physically_anothermale!=.
g abuse_physically_anotherfemale2 = (abuse_physically_anotherfemale <=3 ) if abuse_physically_anotherfemale!=.
g eduadd = yrsedu - myrsedu
g eduadd2 = (yrsedu - myrsedu>0) if yrsedu!=. & myrsedu!=. 

g havemoneytospend2 = (havemoneytospend==1) if havemoneytospend!=.

g speakingupinfra2 = (speakingupinfra==3) if speakingupinfra!=. & speakingupinfra!=98
g speakinguppayment2 = (speakinguppayment==3) if speakinguppayment!=. & speakinguppayment!=98
g speakingupprotest2 = (speakingupprotest==3) if speakingupprotest!=. & speakingupprotest!=98
g canchangecommunity2 = (canchangecommunity>=4) if canchangecommunity!=.
  

g avoidpunishment_nonfarm2 = (avoidpunishment_nonfarm<=2) if avoidpunishment_nonfarm!=. & avoidpunishment_nonfarm<=4
g avoidpunishment_ownwage2 = (avoidpunishment_ownwage<=2) if avoidpunishment_ownwage!=. & avoidpunishment_ownwage<=4
g avoidpunishment_minorexp2 = (avoidpunishment_minorexp<=2) if avoidpunishment_minorexp!=. & avoidpunishment_minorexp<=4
g avoidpunishment_health2 = (avoidpunishment_health<=2) if avoidpunishment_health!=. & avoidpunishment_health<=4
g avoidpunishment_violence2 = (avoidpunishment_violence<=2) if avoidpunishment_violence!=. & avoidpunishment_violence<=4
g avoidpunishment_religious2 = (avoidpunishment_religious<=2) if avoidpunishment_religious!=. & avoidpunishment_religious<=4
g avoidpunishment_tasks2 = (avoidpunishment_tasks<=2) if avoidpunishment_tasks!=. & avoidpunishment_tasks<=4
g avoidpunishment_limitbirth2 = (avoidpunishment_limitbirth<=2) if avoidpunishment_limitbirth!=. & avoidpunishment_limitbirth<=4

g aviodblame_nonfarm2 = (aviodblame_nonfarm<=2) if aviodblame_nonfarm!=. & aviodblame_nonfarm<=4
g aviodblame_ownwage2 = (aviodblame_ownwage<=2) if aviodblame_ownwage!=. & aviodblame_ownwage<=4
g aviodblame_minorexp2 = (aviodblame_minorexp<=2) if aviodblame_minorexp!=. & aviodblame_minorexp<=4
g aviodblame_health2 = (aviodblame_health<=2) if aviodblame_health!=. & aviodblame_health<=4
g aviodblame_violence2 = (aviodblame_violence<=2) if aviodblame_violence!=. & aviodblame_violence<=4
g aviodblame_religious2 = (aviodblame_religious<=2) if aviodblame_religious!=. & aviodblame_religious<=4
g aviodblame_tasks2 = (aviodblame_tasks<=2) if aviodblame_tasks!=. & aviodblame_tasks<=4
g aviodblame_limitbirth2 = (aviodblame_limitbirth<=2) if aviodblame_limitbirth!=. & aviodblame_limitbirth<=4

  
g owninterests_nonfarm2 = (owninterests_nonfarm<=2) if owninterests_nonfarm!=. & owninterests_nonfarm<=4
g owninterests_ownwage2 = (owninterests_ownwage<=2) if owninterests_ownwage!=. & owninterests_ownwage<=4
g owninterests_minorexp2 = (owninterests_minorexp<=2) if owninterests_minorexp!=. & owninterests_minorexp<=4
g owninterests_health2 = (owninterests_health<=2) if owninterests_health!=. & owninterests_health<=4
g owninterests_violence2 = (owninterests_violence<=2) if owninterests_violence!=. & owninterests_violence<=4
g owninterests_religious2 = (owninterests_religious<=2) if owninterests_religious!=. & owninterests_religious<=4
g owninterests_tasks2 = (owninterests_tasks<=2) if owninterests_tasks!=. & owninterests_tasks<=4
g owninterests_limitbirth2 = (owninterests_limitbirth<=2) if owninterests_limitbirth!=. & owninterests_limitbirth<=4


merge m:m a01 using  "Replication.Package\Data\precip_z_clean.dta"
drop _merge

merge m:m a01 using  "Replication.Package\Data\temp_clean.dta"
drop _merge


g precip_z = .
forval x = 1951(1)2015{
	replace precip_z = precip_z`x' if year==`x'
}

g extremeheat = .
forval x = 1961(1)2015{
	replace extremeheat = extremeheat`x' if year==`x'
}



g precip_zL1 = .
forval x = 1951(1)2014{
	replace precip_zL1 = precip_z`x' if year==`x'+1
}

g extremeheatL1 = .
forval x = 1961(1)2014{
	replace extremeheatL1 = extremeheat`x' if year==`x'+1
}


g precip_zL2 = .
forval x = 1951(1)2013{
	replace precip_zL2 = precip_z`x' if year==`x'+2
}

g extremeheatL2 = .
forval x = 1961(1)2013{
	replace extremeheatL2 = extremeheat`x' if year==`x'+2
}


drop precip_z1951 -  extremeheat2015

save "Replication.Package\Data\empowerment.dta", replace

